/******************************************************************************
 * Copyright (C) 2015  671643387@qq.com
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *****************************************************************************/

#ifndef SHARED_UTIL_OPTION_H_
#define SHARED_UTIL_OPTION_H_

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif

#include <string>


namespace Shared {
namespace Util {

    class Option
    {
    public:
        Option(const std::string& name, const std::string& short_name, 
            const std::string& description);
        ~Option(void);

        Option& setRequired(bool required) { _required = required; return *this; }
        bool required(void) const { return _required; }
        Option& setHasArgument(bool hasArg) { _hasArgument = hasArg; return *this; }
        const ::std::string& name(void) const { return _name; }
        const ::std::string& shortName(void) const { return _shortName; }
        const ::std::string& description(void) const { return _description; }
        const ::std::string& value(void) const { return _value; }
        bool valid(void) const { return _valid; }
        void setValid(bool valid) { _valid = valid; }
        bool matchName(const std::string& name);
        bool matchShortName(const std::string& short_name);
        bool hasArgment(void) const { return _hasArgument; }
        void set_value(const ::std::string& value) { _value = value; }

    private:
        std::string _name;
        std::string _shortName;
        std::string _description;
        bool _hasArgument;
        bool _required;
        std::string _value;
        bool _valid;
    };

}}

#endif // SHARED_UTIL_OPTION_H_
